<?php

// +---------------------------------------------+
// |     Copyright  2010 - 2018 InterPhoto       |
// |     http://www.weentech.com                 |
// |     This file may not be redistributed.     |
// +---------------------------------------------+

include('includes/Admin.Core.php');

CheckAccess('manage');

PrintHeader('管理面板首页');

// Should we check for updates?
$updates = Iif(ForceIncomingInt('check'), 1, 0);

$basedata = $DB->query_first("
SELECT (select COUNT(*) FROM " . TABLE_PREFIX . "images) AS totalimages, 
(select COUNT(*)  FROM " . TABLE_PREFIX . "images WHERE actived =0) AS noactiveimages, 
(select COUNT(*)  FROM " . TABLE_PREFIX . "users) AS totalusers, 
(select COUNT(*) FROM " . TABLE_PREFIX . "users WHERE activated =0) AS noactiveusers, 
(select COUNT(*) FROM " . TABLE_PREFIX . "categories) AS totalcategories, 
(select COUNT(*) FROM " . TABLE_PREFIX . "categories WHERE actived =0) AS noactivecategories, 
(select COUNT(*) FROM " . TABLE_PREFIX . "comments) AS totalcomments, 
(select COUNT(*) FROM " . TABLE_PREFIX . "comments WHERE actived =0) AS noactivecomments, 
(select COUNT(*) FROM " . TABLE_PREFIX . "news) AS totalnews, 
(select COUNT(*) FROM " . TABLE_PREFIX . "news WHERE actived =0) AS noactivenews; 
");

PrintSection("欢迎 ".$userinfo['username']." 进入后台管理!");

echo '<table width="100%" bgcolor="#FCFCFC" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td height="8" background="'.TEMPLATEPATH.'images/section/td1_top.gif"></td>
      </tr>
      <tr>
        <td valign="top" height="180" style="padding-left: 28px; padding-top: 18px;">
          欢迎 <font class=ohblueb><u>'.$userinfo['username'].'</u></font> 进入后台管理面板! 为了确保系统安全, 请在关闭前点击 <a href="index.php?logout=1" target="_parent" onclick="return confirm(\'确定退出InterPhoto图片网站管理系统吗?\');"><font class=ohredb><u>退出</u></font></a> 安全离开!<br /><br />
          您在使用'.APP_NAME.'图片网站管理系统过程中有任何问题, 请访问: <a href="http://www.weentech.com" target="_blank"><font class=weentech><u>闻泰网络</u></font></a>!<br /><br /><br />
          '.APP_NAME.'升级提示:<br /><br />
      <table>
	  <tr>
		<td width="150" style="padding-left: 36px;"><b>程序名称</b></td>
		<td width="150" align="center" style="padding-right: 10px;"><b>您现在的版本</b></td>
		<td width="150" align="center" style="padding-right: 10px;"><b>最新版本</b></td>
	  </tr>
	  <tr>
		<td style="padding-left: 28px;"><b>'.APP_NAME.'</b></td>
		<td align="center" style="padding-right: 10px;">' . APP_VERSION . '(UTF-8)免费版</td>
		<td align="center" style="padding-right: 10px;"><span id="interphoto_latest_versioninfo"></span></td>
	  </tr></table>
	  <div id="interphoto_latest_moreinfo"></div>';

	if(!$updates)
	{
		echo '<script type="text/javascript">$("interphoto_latest_versioninfo").innerHTML = "<a href=\"admin.home.php?check=1\">检测最新版本</a>";</script>';
	}
	else
	{
	  echo '<script language="javascript" type="text/javascript" src="http://www.weentech.com/interphoto_version/versioninfo_free.js?temp='.rand().'"></script>
			<script type="text/javascript">
			if(typeof(v) == "undefined"){
				document.getElementById("interphoto_latest_versioninfo").innerHTML = "<font class=ohred>无法连接!</font>";
			}else{
				var interphoto_old_version = parseInt("' . APP_VERSION . '".replace(/\./g,""));
				var interphoto_latest_version = parseInt(v.replace(/\./g,""));
				
				if(interphoto_old_version < interphoto_latest_version ){
					document.getElementById("interphoto_latest_versioninfo").innerHTML = "<font class=ohred>"+v+"</font>";
					document.getElementById("interphoto_latest_moreinfo").innerHTML = "<br><br>请登录 <a href=\"http://www.weentech.com/bbs\" target=\"_blank\">闻泰网络 weentech.com</a> 下载升级!";
				}else{
					document.getElementById("interphoto_latest_versioninfo").innerHTML = "<font class=ohgreen>暂无更新!</font>";
				}
			
			}
			</script>';
	  
	}

echo '</td>
      </tr>
	  <tr>
        <td valign="top" height="210" style="padding-left: 28px; padding-top: 18px;"><b>基本数据统计:</b><br /><br />
		  <table>
		  <tr>
			<td style="padding-right: 8px;" height="28">1)</td>
			<td align="right">用户总数:</td>
			<td style="padding-right: 88px;"><font class=ohgreenb>'.$basedata['totalusers'].'</font></td>
			<td align="right">未激活用户数:</td>
			<td style="padding-right: 88px;"><font class='.Iif($basedata['noactiveusers'], 'ohredb').'>'.$basedata['noactiveusers'].'</font></td>
			<td><a href="admin.users.php" />激活用户</a></td>
		  </tr>
		  <tr>
			<td height="28">2)</td>
			<td align="right">图片总数:</td>
			<td><font class='.Iif($basedata['totalimages'], 'ohgreenb').'>'.$basedata['totalimages'].'</font></td>
			<td align="right">待审图片数:</td>
			<td><font class='.Iif($basedata['noactiveimages'], 'ohredb').'>'.$basedata['noactiveimages'].'</font></td>
			<td><a href="admin.images.php" />审核图片</a></td>
		  </tr>
		  <tr>
			<td height="28">3)</td>
			<td align="right">目录总数:</td>
			<td><font class='.Iif($basedata['totalcategories'], 'ohgreenb').'>'.$basedata['totalcategories'].'</font></td>
			<td align="right">未发布目录数:</td>
			<td><font class='.Iif($basedata['noactivecategories'], 'ohredb').'>'.$basedata['noactivecategories'].'</font></td>
			<td ><a href="admin.icategories.php" />管理目录</a></td>
		  </tr>
		  <tr>
			<td height="28">4)</td>
			<td align="right">评论总数:</td>
			<td><font class='.Iif($basedata['totalcomments'], 'ohgreenb').'>'.$basedata['totalcomments'].'</font></td>
			<td align="right">待审评论数:</td>
			<td><font class='.Iif($basedata['noactivecomments'], 'ohredb').'>'.$basedata['noactivecomments'].'</font></td>
			<td><a href="admin.comments.php" />审核评论</a></td>
		  </tr>
		  <tr>
			<td height="28">5)</td>
			<td align="right">新闻总数:</td>
			<td><font class='.Iif($basedata['totalnews'], 'ohgreenb').'>'.$basedata['totalnews'].'</font></td>
			<td align="right">未发布新闻数:</td>
			<td><font class='.Iif($basedata['noactivenews'], 'ohredb').'>'.$basedata['noactivenews'].'</font></td>
			<td><a href="admin.news.php" />管理新闻</a></td>
		  </tr>
		  </table>
		</td>
	  </tr>
      <tr><td height="6" background="'.TEMPLATEPATH.'images/section/td1_bottom.gif"></td></tr>
      </table>';

EndSection();

PrintFooter();

?>